package pqt;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Toolkit;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Atributos extends JDialog {

	private final JPanel contentPanel = new JPanel();
	JLabel labelInstruccionAtributo ;
	String textosAtributos[] = {"<html><p align='center'>EQUIPO ENSAMBLADO: Verificar que el equipo haya estado en buffer</p></html>",
								"<html><p align='center'>MASCARA VISOR FRENTE: Verificar Colores de acuerdo a patron</p></html>",
								"<html><p align='center'>MASCARA DE DATOS: Verificar pegado</p></html>"};
	int indiceAtributos = 0;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Atributos dialog = new Atributos();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Atributos() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(Atributos.class.getResource("/img/icono.png")));
		setTitle("Control por Atributos");
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setBounds(100, 100, 628, 439);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBackground(new Color(204, 204, 204));
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		labelInstruccionAtributo = new JLabel("New label");
		labelInstruccionAtributo.setHorizontalAlignment(SwingConstants.CENTER);
		labelInstruccionAtributo.setFont(new Font("Tahoma", Font.PLAIN, 40));
		labelInstruccionAtributo.setBounds(10, 30, 592, 150);
		contentPanel.add(labelInstruccionAtributo);
		siguienteAtributo();
		
		
		
//---------------------------------Boton Pasa----------------------------------------------------
		final JButton btnAtributosPasa = new JButton("");
		btnAtributosPasa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				siguienteAtributo();
				
			}
		});
		contentPanel.add(btnAtributosPasa);
		btnAtributosPasa.setFocusable(true);
		btnAtributosPasa.setContentAreaFilled(false);
		btnAtributosPasa.setBorderPainted(false);
		btnAtributosPasa.setBorder(null);
		btnAtributosPasa.setBounds(10, 265, 265, 89);
		btnAtributosPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/PasaAzulGrande.png")));
		//btnAtributosPasa.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/LoginBlancoGrande.png")));
		btnAtributosPasa.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent arg0) {
				btnAtributosPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/PasaVerdeGrande.png")));
				getRootPane().setDefaultButton(btnAtributosPasa);
				
			}
			@Override
			public void mouseExited(MouseEvent e) {
				btnAtributosPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/PasaAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		btnAtributosPasa.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				btnAtributosPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/PasaVerdeGrande.png")));
				getRootPane().setDefaultButton(btnAtributosPasa);
			}
			@Override
			public void focusLost(FocusEvent e) {
				btnAtributosPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/PasaAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
//------------------------------------------------------------------------------------------------		
		final JButton btnAtributosNoPasa = new JButton("");
		btnAtributosNoPasa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				atributoNoOk();
			}
		});
		contentPanel.add(btnAtributosNoPasa);
		btnAtributosNoPasa.setFocusable(true);
		btnAtributosNoPasa.setContentAreaFilled(false);
		btnAtributosNoPasa.setBorderPainted(false);
		btnAtributosNoPasa.setBorder(null);
		btnAtributosNoPasa.setBounds(337, 265, 265, 89);
		btnAtributosNoPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoPasaAzulGrande.png")));
		//btnAtributosNoPasa.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/LoginBlancoGrande.png")));
		btnAtributosNoPasa.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent arg0) {
				btnAtributosNoPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoPasaRojoGrande.png")));
				getRootPane().setDefaultButton(btnAtributosNoPasa);
				
			}
			@Override
			public void mouseExited(MouseEvent e) {
				btnAtributosNoPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoPasaAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		btnAtributosNoPasa.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				btnAtributosNoPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoPasaRojoGrande.png")));
				getRootPane().setDefaultButton(btnAtributosNoPasa);
			}
			@Override
			public void focusLost(FocusEvent e) {
				btnAtributosNoPasa.setIcon(new ImageIcon(testBoton.class.getResource("/img/NoPasaAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		
		
		
		
	}

void siguienteAtributo()
{
	if(indiceAtributos>=textosAtributos.length)
	{
	dispose();
	}
	else
	{
	labelInstruccionAtributo.setText(textosAtributos[indiceAtributos]);
	indiceAtributos++;
	}
}

void atributoNoOk()
{
	AtributoNoOk nook = new AtributoNoOk();
	nook.setModal(true);
	
	nook.setLocationRelativeTo(null);
	nook.setVisible(true);
	siguienteAtributo();
	
}


}
